package sample.sub1.section03

import scala.io.Source;

class TestFile {
	def show() {
	  val lines = Source.fromFile("src/sample/sub1/section3/TestFile.scala").getLines.toList;
	  val longestLine = lines.reduceLeft(
	      (a, b) => if (a.length > b.length) a else b
	      );
	  val maxWidth = widthOfLength(longestLine);
	  
	  for(line <- lines) {
	    val num = maxWidth - widthOfLength(line)
	    val padding = " " * num
	    println(padding + line.length + "|" + line)
	  }
	}
	
	def widthOfLength(s : String) = s.length.toString.length;
}